#pragma once

#include <wx/wx.h>
#include <list>
#include "SP.h"
#include "CECascadeSystem.h"
#include "CEPropertyPane.h"

class CEModuleCtrl;
class CEEmitterCtrl;
class CEEmitterCtrlPane;
class CEEmitterList;

//-------------------------------------------------------------------------
class CEModuleCtrl : public wxPanel
{
public:
	CEModuleCtrl( CEEmitterCtrlPane* pOwner, wxString label );
	virtual ~CEModuleCtrl();

	enum
	{
		ID_CEMC_SHIFTUP,
		ID_CEMC_SHIFTDOWN,
		ID_CEMC_DELETE,
	};

	static void FocusModule( CEModuleCtrl* );
	void	OnMouse( wxMouseEvent& );
	bool Destroy();

	void SetColours( wxColour BGColour, wxColour FocusColour );

	wxString GetName(){ return m_pSTModuleName->GetLabel(); }

	SP::SPModule* GetSPModule(){ return m_pSPModule; }

protected:
	//std::list<CEModuleCtrl*> m_ModuleList;
	virtual void PopupMenu( int x, int y );	
	
	CEEmitterCtrlPane* m_pOwnerPane;

private:
	void ShiftUp( wxCommandEvent& );
	void ShiftDown( wxCommandEvent& );
	void DeleteModel( wxCommandEvent& );

	void SetCtrlFocus( bool bFocus );
	bool m_bFocus;
	wxColour m_BGColour;
	wxColour m_FocusColour;
	wxMenu* m_pMenu;
	wxStaticText* m_pSTModuleName;

	CEPropertyGrid* m_pPropertyGrid;

	SP::SPModule* m_pSPModule;

	DECLARE_EVENT_TABLE();
};



//-------------------------------------------------------------------------
class CEEmitterCtrl : public CEModuleCtrl
{
public:	
	CEEmitterCtrl( CEEmitterCtrlPane* pOwner, wxString label );
	virtual ~CEEmitterCtrl();

protected:	
	void PopupMenu( int x, int y );
};


//-------------------------------------------------------------------------
class CEEmitterCtrlPane : public wxPanel
{
public:
	CEEmitterCtrlPane( CEEmitterList* parent, wxString label );
	~CEEmitterCtrlPane();

	enum
	{
		// 
		ID_CEECP_DELETE,

		// General
		ID_CEECP_NEW_ROTATION,
		ID_CEECP_NEW_TRANSLATION,
		ID_CEECP_NEW_SCALE,

		ID_CEECP_NEW_BLENDSTATE,
		ID_CEECP_NEW_DEPTHSTENCILSTATE,
		ID_CEECP_NEW_RASTERIZERSSTATE,

		ID_CEECP_NEW_COLOUR,
		ID_CEECP_NEW_COLLOSION,

		// Particle
		ID_CEECP_NEW_INITPOS,
		ID_CEECP_NEW_POSOVERLIFE,
		ID_CEECP_NEW_INITVELO,
		ID_CEECP_NEW_VELOOVERLIFE,
		ID_CEECP_NEW_INITACCEL,
		ID_CEECP_NEW_ACCELOVERLIFE,
		ID_CEECP_NEW_INITSIZE,
		ID_CEECP_NEW_SIZEOVERLIFE,
		ID_CEECP_NEW_INITCOLOUR,
		ID_CEECP_NEW_COLOUROVERLIFE,
		ID_CEECP_NEW_INITALPHA,
		ID_CEECP_NEW_ALPHAOVERLIFE,

		// Beam
		ID_CEECP_NEW_BEAMSOURCE,
		ID_CEECP_NEW_BEAMTARGET,
		ID_CEECP_NEW_BEAMNOISE,
		ID_CEECP_NEW_BEAMSHAPE,
		ID_CEECP_NEW_BEAMWIDTH,
		ID_CEECP_NEW_BEAMCOLOUR,

		// Mesh

		// AnimTrial

		// 
		ID_CEECP_NEW_END,
		ID_CEECP_NEW_START = ID_CEECP_NEW_ROTATION,
	};

	void PopupMenu( int x, int y );
	
	void RefreshModules();
	void ShiftUpModule( CEModuleCtrl* pMC );
	void ShiftDownModule( CEModuleCtrl* pMC );
	void RemoveModule( CEModuleCtrl* pMC );

	SP::SPEmitter* GetSPEmitter(){ return m_pSPEmitter; }

protected:
	std::list<CEModuleCtrl*> m_ModuleList;
	CEEmitterCtrl* m_pEmitterCtrl;
	wxBoxSizer* m_pBoxSizer;
	CEEmitterList* m_pOwnerEmitterList;
	wxMenu* m_pMenu;

	SP::SPEmitter* m_pSPEmitter;

	void OnNewModule( wxCommandEvent& );
	void OnDeleteEmitter( wxCommandEvent& );
};



//-------------------------------------------------------------------------
class CEEmitterList : public wxScrolledWindow
{
public:
	CEEmitterList( wxWindow* parent );
	~CEEmitterList();

	enum
	{
		ID_CEEL_NEW_ANIMTRAIL,
		ID_CEEL_NEW_BEAM,
		ID_CEEL_NEW_PARTICLE,
		ID_CEEL_NEW_MESH,

		ID_CEEL_NEW_START = ID_CEEL_NEW_ANIMTRAIL,
		ID_CEEL_NEW_END = ID_CEEL_NEW_MESH + 1
	};

	void OnMouse( wxMouseEvent& event );
	wxPanel* GetClientPanel(){ return m_pClientPanel; }
	
	void RefreshEmitters();
	void RemoveEmitter( CEEmitterCtrlPane* p );

private:
	void OnMenu();

	//SPParticleSystem* m_pParticleSystem;
	wxPanel* m_pClientPanel;
	wxBoxSizer* m_pClientSizer;
	wxMenu* m_pMenu;

	std::list<CEEmitterCtrlPane*> m_EmitterCtrlPaneList;
	
	void OnNewEmitter( wxCommandEvent& );
	DECLARE_EVENT_TABLE()
};
